package cn.edu.ctbu.test.service.impl;


import cn.edu.ctbu.test.domain.Score;
import cn.edu.ctbu.test.dao.ScoreRepository;
import cn.edu.ctbu.test.domain.Student;
import cn.edu.ctbu.test.service.ScoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.*;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ScoreServiceImpl implements ScoreService {
    @Autowired
    private ScoreRepository scoreRepository;

    @Override
    public List<Score> findAll(){

        return scoreRepository.findAll();
    }



    public Page<Score> findAll(Example<Score> score,Pageable pageable){

        return scoreRepository.findAll(score,pageable);
    }






    public List<Score> findByStudentId(Long studentId){

        return scoreRepository.findByStudentId(studentId);

    }




    public Score insert(Score score){

        return scoreRepository.save(score);
    }

    public void delete(Long Id){
        Score score=new Score();
        score.setId(Id);
        scoreRepository.delete(score);
    }

    public Score getById(Long Id){

        Score score=scoreRepository.findById(Id).orElse(null);

        return score;
    }

    public Score update(Score score){

        return  scoreRepository.save(score);
    }

    public Page<Score> findAll(Pageable pageable){


        return scoreRepository.findAll(pageable);

    }




 
}
